/**
 * interation-event.js
 * todo 处理comet退回来的相应事件，解析json对象
 */
function AgentReady() {
	onAgentReady();
}

function initFailed() {
	onInitFailed();
}

function handleError(result) {
	result = toJSON(result);
	onError(result);
}
// --------------------------------新添加，之前只做参考--------------------------

/**
 * handleAgentStatusChanged 座席状态改变
 * 
 * @param result
 *            json串
 * @return
 */
function handleAgentStatusChanged(result) {
	result = toJSON(result);
	onAgentStatusChanged(result);
}

/**
 * CallStateChangeMessage 拨打电话状态改变
 * 
 * @param result
 *            json串
 * @return
 */
function CallStateChangeMessage(result) {
	onCallStateChangeMessage(result)
}

/**
 * emailStateChangeMessage 会话状态变化
 * 
 * @param result
 *            json串
 * @return
 */
function emailStateChangeMessage(result) {
	onEmailStateChangeMessage(result);
}

/**
 * chatStateChangeMessage 会话状态变化
 * 
 * @param result
 *            json串
 * @return
 */
function chatStateChangeMessage(result) {
	onChatStateChangeMessage(result);
}

function thirdMediaStateChangeMessage(result){
	onThirdMediaStateChangeMessage(result);
}

/**
 * chatMessageReceive 收到comet推送过来的消息
 * 
 * @param result
 *            json数组
 * @return
 */
function chatMessageReceive(result) {
	onChatMessageReceive(result);
}

/**
 * callMessageError 错误信息处理
 * @param result
 * @return
 */
function callMessageError(result){	
	onCallMessageError(result);
}

function participantsUpdatedMessage(result){
	onParticipantsUpdatedMessage(result);
}
function handleForcedAgentStatusChanged(result) {
	result = toJSON(result);
	onForcedAgentStatusChanged(result);
}

function handleConnectionStatusChanged(result) {
	result = toJSON(result);
	onConnectionStatusChanged(result);
}

function handleForcedConnectionStatusChanged(result) {
	result = toJSON(result);
	onForcedConnectionStatusChanged(result);
}

function handleInteractionAdded(result) {
	try {
		result = toJSON(result);
		onInteractionAdded(result);
	} catch (e) {
		alert(e);
	}
}

function handleInteractionUpdated(result) {
	try {
		result = toJSON(result);
		onInteractionUpdated(result);
	} catch (e) {
		alert(e);
	}
}

function handleInteractionRemoved(result) {
	try {
		result = toJSON(result);
		onInteractionRemoved(result);
	} catch (e) {
		alert(e);
	}
}

function handleUserEvent(result) {
	try {
		result = toJSON(result);
		onUserEvent(result);
	} catch (e) {
		alert(e);
	}
}

function handleMonitoringEvent(result) {
	try {
		result = toJSON(result);
		onMonitoringEvent(result);
	} catch (e) {
		alert(e);
	}
}

function handleRegisteredEvent(result) {
	try {
		result = toJSON(result);
		onRegisteredEvent(result);
	} catch (e) {
		alert(e);
	}
}

function handleSessionInfo(result) {
	result = toJSON(result);
	onSessionInfo(result);
}

function handlePartyJoin(result) {
	result = toJSON(result);
	onPartyJoin(result);
}

function handlePartyLeft(result) {
	result = toJSON(result);
	onPartyLeft(result);
}

function toJSON(result) {
	return result;
}